// 代言人侧相关API
import { get, post } from '../common/ajax';
import { SPN_ACTIVITY_URL } from '../constants/url';
import { dealActivityStats } from '../biztools/stats';
import { ACTIVITY_OWNER_VALUE } from '../constants/activity';


/**
 * 代言活动
 */
export const spokesActivity = async (params) => {
    const { spokesmanId, endorseActivityId } = params;
    const res = await post(SPN_ACTIVITY_URL.create(spokesmanId), { endorseActivityId });
    return res.data || false;
};

/**
 * 活动收入数据统计
 * @param {String} params spokesmanId 代言人id
 * @param {String} params activityId 活动id
 */
export const statsIncomeActivity = async (params) => {
    const { spokesmanId, activityId } = params;
    const res = await get(SPN_ACTIVITY_URL.statsIncome(activityId, spokesmanId));
    return res.data ? dealActivityStats(ACTIVITY_OWNER_VALUE.spokesman, res.data) : {};
};
